/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package view.centerPanels;

import controller.Data;
import static java.awt.Component.LEFT_ALIGNMENT;
import java.awt.FlowLayout;
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JLabel;
import javax.swing.JTextField;
import view.main.MainGUI;
import weka.classifiers.bayes.NaiveBayes;
import weka.core.SerializationHelper;

/**
 *
 * @author Dusan Dudukovic
 */
public class ClassificationPnlCenterPredict extends javax.swing.JPanel {

    /**
     * Creates new form ClassificationPnlCenter
     */
    public ClassificationPnlCenterPredict() {
        initComponents();

        setSize(MainGUI.getInstance().getPnlCenter().getWidth(), MainGUI.getInstance().getPnlCenter().getHeight());
        setVisible(true);

        if (model.clasification.ModelFinder.arrayOfModels() != null) {
            String[] nizModela = model.clasification.ModelFinder.arrayOfModels();

//        final JComboBox combo = new JComboBox(nizModela);
//        combo.setBounds(500, 500, 200, 200);
//        combo.setVisible(true);
//        this.add(combo);
            jComboBox1.removeAllItems();

            for (int i = 0; i < nizModela.length; i++) {
                jComboBox1.addItem(makeObj(nizModela[i]));
            }
        }

    }

    private Object makeObj(final String item) {
        return new Object() {
            public String toString() {
                return item;
            }
        };
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jComboBox1 = new javax.swing.JComboBox();
        jLabel2 = new javax.swing.JLabel();
        jButton1 = new javax.swing.JButton();
        jPanelStart = new javax.swing.JPanel();

        jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));

        jLabel2.setText("Models:");

        jButton1.setText("Start");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(29, 29, 29)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jComboBox1, 0, 160, Short.MAX_VALUE)
                        .addGap(211, 211, 211))
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 120, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 70, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jPanelStart, javax.swing.GroupLayout.PREFERRED_SIZE, 345, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(18, 18, 18)
                .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(35, 35, 35)
                .addComponent(jButton1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jPanelStart, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );
    }// </editor-fold>//GEN-END:initComponents

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
//        MainGUI.getInstance().getPnlCenter().removeAll();
//        MainGUI.getInstance().getPnlCenter().add(new jPanelStart2());
//        MainGUI.getInstance().getPnlCenter().validate();
//        MainGUI.getInstance().getPnlCenter().repaint();

        ArrayList<JLabel> listaLabela = new ArrayList<JLabel>();
        ArrayList<JTextField> listaFildova = new ArrayList<JTextField>();

        jPanelStart.setLayout(new FlowLayout((int) LEFT_ALIGNMENT));

        int numOfAt = Data.getInstance().getInstances().numAttributes();

        for (int i = 0; i < numOfAt - 1; i++) {
            String name = Data.getInstance().getInstances().attribute(i).name();
            listaLabela.add(new JLabel(name));
            jPanelStart.add(listaLabela.get(i));
            listaLabela.get(i).setText(name);
        }


    }//GEN-LAST:event_jButton1ActionPerformed


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton1;
    private javax.swing.JComboBox jComboBox1;
    private javax.swing.JLabel jLabel2;
    public static javax.swing.JPanel jPanelStart;
    // End of variables declaration//GEN-END:variables
}
